export default {
  bind: (el, binding) => {
    let num = null
    let numTs = null
    if (binding.value >= 10000) {
      if (binding.modifiers.number) {
        numTs = (binding.value * 1 / 10000).toLocaleString()
        num = `${numTs}w`
      } else {
        numTs = (binding.value * 1 / 10000).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
        num = `${numTs}w`
      }
    } else {
      if (binding.modifiers.number) {
        num = (binding.value * 1).toLocaleString()
      } else {
        num = (binding.value * 1).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
      }
    }
    el.innerHTML = num
  },
  update: (el, binding) => {
    let num = null
    let numTs = null
    if (binding.value >= 10000) {
      if (binding.modifiers.number) {
        numTs = (binding.value * 1 / 10000).toLocaleString()
        num = `${numTs}w`
      } else {
        numTs = (binding.value * 1 / 10000).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
        num = `${numTs}w`
      }
    } else {
      if (binding.modifiers.number) {
        num = (binding.value * 1).toLocaleString()
      } else {
        num = (binding.value * 1).toFixed(2).replace(/\d{1,3}(?=(\d{3})+(\.\d*)?$)/g, '$&,')
      }
    }
    el.innerHTML = num
  }
}
